home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Object Oriented Applicat…isualAge for C++ for OS/2
/
Object-Oriented Application Development with VisualAGE for C++ for OS2.iso
/
makedb.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-03-06
|
5KB
|
150 lines
/* REXX */
/*
COPYRIGHT: Copyright (C) International Business Machines Corp., 1995.
DISCLAIMER OF WARRANTIES:
The following [enclosed] code is sample code created by IBM
Corporation. This sample code is not part of any standard IBM product
and is provided to you solely for the purpose of assisting you in the
development of your applications. The code is provided "AS IS",
without warranty of any kind. IBM shall not be liable for any damages
arising out of your use of the sample code, even if they have been
advised of the possibility of such damages.
*/
/* Get the path of the VisualAge C++ installation */
env='OS2ENVIRONMENT';
BasePath = VALUE('CPPMAIN',,env);
VideoPath = VALUE('VR_VIDEO',,env);
if BasePath="" then do
say "Error: VISUAL environment variable not set."
call Finished
end
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
say "Creating the database REAL"
say "Enter the target drive letter: "
pull drive
if ( DATATYPE(drive,M) = 1 & LENGTH(drive) = 1 ) then do
say "WARNING: The database REAL will be deleted if it exists,"
say "and all data in that database will be lost. REAL will be"
say "(re)created on drive" drive", okay(y|n)?"
pull okay
if okay = "Y" then do
if ( SysSearchPath( 'PATH', 'db2.exe' ) \= '' ) then do
db2start
DBM = 'db2.exe'
end
else if ( SysSearchPath( 'PATH', 'dbm.cmd' ) \= '' ) then do
startdbm
DBM = 'call dbm'
end
else do
say "DB2 is not installed."
call Finished
end
say "Dropping REAL... Any failure of this step may be ignored."
DBM "drop database REAL"
say "Any failures after this point must be investigated - consult the DB2/2 Messages Guide, resolve and retry."
say "Creating REAL..."
DBM "create database REAL on" drive
DBM "connect to REAL"
file = 'LIST.TAB'
stat = STREAM(file,'C','open read') /* open file*/
stmt = '' /* build statement*/
complete = 0
do while lines(file)>0
line = linein(file)
line = strip(line,'T')
if left(line,2)='--' then iterate /* ignore comments*/
if left(line,2)='/*' then iterate /* ignore comments*/
lg = length(line)
if lg>0 then /* check for ;*/
if substr(line,lg,1) = ';' then do
complete = 1
line = left(line,lg-1)
end
if stmt='' then stmt = left(line,72)' '
else stmt = stmt''left(line,72)' '
if complete then do /* submit complete stmt*/
stmt = strip(stmt,'T')
stmt = space(stmt) /* remove extra blanks*/
DBM stmt
ok = RC
if ok \= 0 then do
call finished /* the loop*/
end
stmt = ''
complete = 0
end
end
if lines(file) > 0 then runretcode = 8
stat = STREAM(file,'C','close') /* close file*/
if (VideoPath <> "")
Then
Do
DBM "UPDATE MULTIDOC SET FILENAME='"VideoPath"\HOME.AVI' WHERE MULTIDOC_ID='11111'"
DBM "UPDATE MULTIDOC SET FILENAME='"VideoPath"\MAUI.AVI' WHERE MULTIDOC_ID='22222'"
DBM "UPDATE MULTIDOC SET FILENAME='"VideoPath"\FOUNTHP.AVI' WHERE MULTIDOC_ID='33333'"
DBM "UPDATE MULTIDOC SET FILENAME='"VideoPath"\GALLERY.AVI' WHERE MULTIDOC_ID='44444'"
DBM "UPDATE MULTIDOC SET FILENAME='"VideoPath"\HOUSWALK.AVI' WHERE MULTIDOC_ID='55555'"
DBM "UPDATE MULTIDOC SET FILENAME='"VideoPath"\BIGHOUSE.AVI' WHERE MULTIDOC_ID='66666'"
End
DBM "commit"
DBM "connect reset"
BindPath = VALUE('VR_BIND',,env);
if (BindPath <> "")
Then
Do
say "Binding bnd files to the database REAL..."
sqlbind BindPath"\BuyAddv.bnd REAL"
sqlbind BindPath"\BuyAddv.bnd REAL"
sqlbind BindPath"\Buyerv.bnd REAL"
sqlbind BindPath"\BuyInfv.bnd REAL"
sqlbind BindPath"\BuyLogv.bnd REAL"
sqlbind BindPath"\ListArev.bnd REAL"
sqlbind BindPath"\MarkInfv.bnd REAL"
sqlbind BindPath"\Multidov.bnd REAL"
sqlbind BindPath"\Preferev.bnd REAL"
sqlbind BindPath"\PropAddv.bnd REAL"
sqlbind BindPath"\PropALov.bnd REAL"
sqlbind BindPath"\Propertv.bnd REAL"
sqlbind BindPath"\PropLogv.bnd REAL"
sqlbind BindPath"\SaleTrav.bnd REAL"
say "Binding daxscl.bnd to the database REAL..."
sqlbind BasePath"\bnd\daxscl.bnd REAL"
End
Else
say "Bind files not installed on your machine. Install the full application"
say "REAL Creation complete."
end
else
say "REAL creation cancelled."
end
else do
say "Invalid drive letter " drive
say "REAL was not created."
end
call Finished
Aborted:
say "Error creating database." rc
say "Consult the DB2/2 Messages Guide for more information."
call Finished
Finished:
say "Press enter to exit."
pull done
exit